package com.qfedu.openplateform.gateway.config;


import com.qfedu.openplateform.gateway.filter.LogFilter;
import com.qfedu.openplateform.gateway.filter.SignFilter;
import com.qfedu.openplateform.gateway.filter.TimerFilter;
import com.qfedu.openplateform.gateway.filter.TokenFilter;

import com.qfedu.openplateform.gateway.filter.*;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class FilterConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        // 将自定的 日志拦截器 加入到 springmvc
        registry.addInterceptor(new LogFilter()).addPathPatterns("/**");

        registry.addInterceptor(new SignFilter()).addPathPatterns("/**");

        // token 拦截器 拦截所有的 路径 不拦截 /login
        registry.addInterceptor(new TokenFilter()).addPathPatterns("/**").excludePathPatterns("/login");
        //幂等级拦截TimerFilter
        registry.addInterceptor(new IdempotentFilter()).addPathPatterns("/**");
        //系统参数拦截器 拦截所有的路径
        registry.addInterceptor(new SystemParamFilter()).addPathPatterns("/**");
        registry.addInterceptor(new TimerFilter()).addPathPatterns("/**");

    }
}
